<?php
class debug extends base{
	
	public $_div = true;

	/**
	 * 
	 */
	public function __construct(){
		echo '<script type="text/javascript" src="/public/js/core/drag.js"></script>';
	}
	/**
	 * 拦截所有方法
	 **/
	public function __call($method,$parameter){
		$method = '_'.$method;
		if(!SYS_DEBUG) return;
		return $this->$method($parameter);
	}
	/**
	 * 打印输出
	 **/
	private function _dump($var){
		$str = "<pre>".var_export($var[0],true)."</pre>";
		echo $this->_div($str);
	}
	
	/**
	 * 浮动层输出
	 * @param string $contents
	 * @return string
	 */
	private function _div($contents){
		if($this->_div===false){
			return $contents;
		}
		$id 	= 'debug_div_'.uniqid();
		$html 	= "<div id='{$id}' style='position:absolute;left:400px;top:300px;background:#E6E7E1;border:1px red solid;'><div class='title'>DEBUG</div>{$contents}</div>";
		$js 	= '<script type="text/javascript">Endrag.bind("'.$id.'");</script>'."\n";
		return $html.$js;
	}
}
?>